﻿namespace Growatt.ShinebusServiceUploadPack.Service.Jwt
{
    using System;
    using System.Text;

    public class JwtKeyGenerator
    {
        public static string GenerateJwtKey(int byteLength)
        {
            // 生成随机字节
            byte[] randomBytes = new byte[byteLength];
            using (System.Security.Cryptography.RandomNumberGenerator rng = System.Security.Cryptography.RandomNumberGenerator.Create())
            {
                rng.GetBytes(randomBytes);
            }

            // 将字节转换为 Base64 字符串
            return Encoding.UTF8.GetString(randomBytes);
        }
    }

}
